package com.xbongbong.saas.model.impl;

import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.saas.domain.dao.WorkOrderTagDao;
import com.xbongbong.saas.domain.entity.WorkOrderTagEntity;
import com.xbongbong.saas.model.WorkOrderTagModel;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import java.util.Objects;

/**
 * @author ly1666
 * @date 2019/3/19 下午2:17
 * @since v1.0
 * @version v1.0
 */
@Service("WorkOrderTagModel")
public class WorkOrderTagModelImpl implements WorkOrderTagModel {
    @Resource
    private WorkOrderTagDao workOrderTagDao;

    @Override
    public Integer insert(WorkOrderTagEntity entity) throws XbbException {
        return workOrderTagDao.insert(entity);
    }

    @Override
    public Integer update(WorkOrderTagEntity entity) throws XbbException {
        return workOrderTagDao.update(entity);
    }

    @Override
    public List<WorkOrderTagEntity> findEntitys(Map<String, Object> param){

        return workOrderTagDao.findEntitys(param);

    }

    @Override
    public Integer getEntitysCount(Map<String, Object> param) {
        return workOrderTagDao.getEntitysCount(param);
    }

    @Override
    public List findEntitysWithoutSub(Map<String, Object> param) {
        return null;
    }

    @Override
    public Integer minusNum(Map<String,Object> modelMap,Map<Integer,Integer> minusNumMap){
        return workOrderTagDao.minusNum(modelMap,minusNumMap);
    }

    @Override
    public Integer save(WorkOrderTagEntity workOrderTagEntity) throws XbbException {
        if (workOrderTagEntity.getId() == null || Objects.equals(0L, workOrderTagEntity.getId())){
            return insert(workOrderTagEntity);
        }
        return update(workOrderTagEntity);
    }

    @Override
    public Integer numOperation(Map<String,Object> modelMap){
        return workOrderTagDao.numOperation(modelMap);
    }

    @Override
    public WorkOrderTagEntity getByKey(Long key, String corpid) {
        return workOrderTagDao.getByKey(key,corpid);
    }
}
